package com.atguigu.classes.preconditions;

import java.util.Scanner;

/**
 * @program: myIDEA
 * @description: 输入年份判断天数
 * @author: Mr.zjx
 * create: 2021-07-04-23-12
 **/
public class Test10 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入年份：");
        int year = scanner.nextInt();

        System.out.println("请输入月份：");
        int month = scanner.nextInt();
        if (year >=1970){
            if (month >=1 && month<=12){
                if (month == 1 || month == 3 || month == 5 || month == 7|| month == 8|| month == 10|| month == 12){
                    System.out.println("这个月有31天");
                }
                else if (month == 4 || month == 6 || month == 9 || month == 11){
                    System.out.println("这个月有30天");
                }else {
                    if(year % 4 ==0 && year % 100 != 0 || year %100 == 0){
                        System.out.println("这个月有29天");
                    }else {
                        System.out.println("这个月有28天");
                    }
                }
            }else
            System.out.println("输入错误，输入的月份应该是1-12之间，请从新输入：");
        }else {
            System.out.println("输入错误，输入的年份不能小于1970年，请重新输入：");
        }
    }
}
